OPC Studio User's Guide and Reference
OPC Wizard Node Objects
Fundamentals > OPC Wizard Fundamentals > OPC Wizard Data Model > OPC Wizard Node Objects
In This Topic

Server Nodes and their Purpose

Every OPC UA server contains a set of interconnected nodes (an address space) and exposes it to OPC UA clients. The nodes form a general graph (a full "mesh"), where the edges that connect the vertices (nodes) are called references.

There are many pre-defined nodes described by OPC UA specifications that exist in the OPC UA server, and OPC Wizard takes care of implementing them automatically. and When you develop an OPC UA sever using OPC Wizard, you are actually defining a subset of the address space - a tree of custom nodes that "lives" under the standard Objects folder in the OPC UA address space.

Every server node that you define in OPC Wizard is represented by an instance of some node type derived from the UAServerNode Class. The concrete server node can be one of the following:

The inheritance hierarchy of the server node classes looks like this: 

 

Each server node has a name (a string; Name Property). The name must be unique among the sub-nodes of the parent node.

If your implementation needs it, a node can be associate any object you like. This is done using the State Property of the node.

Server nodes, in general, can contain sub-nodes, forming a hierarchy (a tree). However, not all types of sub-nodes are allowed everywhere. Following rules apply:

The picture below shows an example of "node space", a tree of nodes under the Objects folder. 

 

Various combinations of server nodes can be seen on the example picture, demonstrating that:

Constructing the Node Space

The basic way of populating the node space is as follows:

  1. Create the server node of the desired type (UADataVariable Class or UAFolder Class) using its constructor.
  2. Set additional properties of the created node as needed, and hook to its events.
  3. Add the new server node to the parent node by calling the Add Method on the parent node.
  4. Repeat for all your nodes.

The procedure above can always be used. The OPC Wizard, however, has several useful features that can make the process easier:

The following example adds nodes to the Objects folder.

.NET

// This example shows how to add nodes (data variables and folders) to the Objects folder in the address space.
// You can use any OPC UA client, including our Connectivity Explorer and OpcCmd utility, to connect to the server. 
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client, server and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-OPCStudio-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.NodeSpace;

namespace UAServerDocExamples._EasyUAServer
{
    class Objects
    {
        public static void Main1()
        {
            // Instantiate the server object.
            // By default, the server will run on endpoint URL "opc.tcp://localhost:48040/".
            var server = new EasyUAServer();

            // Create a data variable and a folder in the Objects folder, and a data variable under the custom folder.
            var constantDataVariable = UADataVariable.CreateIn(server.Objects, "Constant").ConstantValue("abc");
            var folder = UAFolder.CreateIn(server.Objects, "Folder");
            var readWriteDataVariable = UADataVariable.CreateIn(folder, "ReadWrite").ReadWriteValue(0); // read-write register

            // Start the server.
            Console.WriteLine("The server is starting...");
            server.Start();

            Console.WriteLine("The server is started.");
            Console.WriteLine();

            // Let the user decide when to stop.
            Console.WriteLine("Press Enter to stop the server...");
            Console.ReadLine();

            // Stop the server.
            Console.WriteLine("The server is stopping...");
            server.Stop();

            Console.WriteLine("The server is stopped.");
        }
    }
}
' This example shows how to add nodes (data variables and folders) to the Objects folder in the address space.
' You can use any OPC UA client, including our Connectivity Explorer and OpcCmd utility, to connect to the server. 
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET .
' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
' a commercial license in order to use Online Forums, and we reply to every post.

Imports System
Imports OpcLabs.EasyOpc.UA
Imports OpcLabs.EasyOpc.UA.NodeSpace

Namespace _EasyUAServer
    Partial Friend Class Objects
        Shared Sub Main1()
            ' Instantiate the server object.
            ' By default, the server will run on endpoint URL "opc.tcp://localhost:48040/".
            Dim server = New EasyUAServer()

            ' Create a data variable and a folder in the Objects folder, and a data variable under the custom folder.
            Dim constantDataVariable = UADataVariable.CreateIn(server.Objects, "Constant").ConstantValue("abc")
            Dim folder = UAFolder.CreateIn(server.Objects, "Folder")
            Dim readWriteDataVariable = UADataVariable.CreateIn(folder, "ReadWrite").ReadWriteValue(0) ' read-write register

            ' Start the server.
            Console.WriteLine("The server is starting...")
            server.Start()

            Console.WriteLine("The server is started.")
            Console.WriteLine()

            ' Let the user decide when to stop.
            Console.WriteLine("Press Enter to stop the server...")
            Console.ReadLine()

            ' Stop the server.
            Console.WriteLine("The server is stopping...")
            server.Stop()

            Console.WriteLine("The server is stopped.")
        End Sub
    End Class
End Namespace

The following example creates nested folders.

.NET

// This example shows how to folders nested in another folders.
// You can use any OPC UA client, including our Connectivity Explorer and OpcCmd utility, to connect to the server. 
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client, server and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-OPCStudio-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.NodeSpace;

namespace UAServerDocExamples._UAFolder
{
    class _Building
    {
        public static void Nested()
        {
            // Instantiate the server object.
            // By default, the server will run on endpoint URL "opc.tcp://localhost:48040/".
            var server = new EasyUAServer();

            // Create a structure where a folder contains another folders, and the nested folders contains data variables.
            server.Add(new UAFolder("Folder1")
            {
                new UAFolder("NestedFolder1")
                {
                    new UADataVariable("Constant").ConstantValue(42)
                },
                new UAFolder("NestedFolder2"),
                new UADataVariable("Constant").ConstantValue("abc")
            });
            server.Add(new UAFolder("Folder2"));

            // Start the server.
            Console.WriteLine("The server is starting...");
            server.Start();

            Console.WriteLine("The server is started.");
            Console.WriteLine();

            // Let the user decide when to stop.
            Console.WriteLine("Press Enter to stop the server...");
            Console.ReadLine();

            // Stop the server.
            Console.WriteLine("The server is stopping...");
            server.Stop();

            Console.WriteLine("The server is stopped.");
        }
    }
}
' This example shows how to folders nested in another folders.
' You can use any OPC UA client, including our Connectivity Explorer and OpcCmd utility, to connect to the server. 
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET .
' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
' a commercial license in order to use Online Forums, and we reply to every post.

Imports System
Imports OpcLabs.EasyOpc.UA
Imports OpcLabs.EasyOpc.UA.NodeSpace

Namespace _UAFolder
    Partial Friend Class _Building
        Shared Sub Nested()
            ' Instantiate the server object.
            ' By default, the server will run on endpoint URL "opc.tcp://localhost:48040/".
            Dim server = New EasyUAServer()

            ' Create a structure where a folder contains another folders, and the nested folders contains data variables.
            server.Add(New UAFolder("UAFolder") From
            {
                New UAFolder("NestedFolder1") From
                {
                    New UADataVariable("Constant").ConstantValue(42)
                },
                New UAFolder("NestedFolder2"),
                New UADataVariable("Constant").ConstantValue("abc")
            })
            server.Add(New UAFolder("Folder2"))

            ' Start the server.
            Console.WriteLine("The server is starting...")
            server.Start()

            Console.WriteLine("The server is started.")
            Console.WriteLine()

            ' Let the user decide when to stop.
            Console.WriteLine("Press Enter to stop the server...")
            Console.ReadLine()

            ' Stop the server.
            Console.WriteLine("The server is stopping...")
            server.Stop()

            Console.WriteLine("The server is stopped.")
        End Sub
    End Class
End Namespace

The following example creates data variables nested in other nodes.

.NET

// This example shows how to create data variables nested in folders or other data variables.
// You can use any OPC UA client, including our Connectivity Explorer and OpcCmd utility, to connect to the server. 
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client, server and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-OPCStudio-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.NodeSpace;

namespace UAServerDocExamples._UADataVariable
{
    class _Building
    {
        public static void Nested()
        {
            // Instantiate the server object.
            // By default, the server will run on endpoint URL "opc.tcp://localhost:48040/".
            var server = new EasyUAServer();

            // Create a data variable, and another data variable nested inside it.
            server.Add(new UADataVariable("Constant")
                {
                    new UADataVariable("NestedConstant").ConstantValue("abc")
                }.ConstantValue(42));

            // Create a folder, and a data variable nested inside it.
            server.Add(new UAFolder("Folder")
                {
                    new UADataVariable("ReadWrite").ReadWriteValue(0)  // read-write register
                });

            // Start the server.
            Console.WriteLine("The server is starting...");
            server.Start();

            Console.WriteLine("The server is started.");
            Console.WriteLine();

            // Let the user decide when to stop.
            Console.WriteLine("Press Enter to stop the server...");
            Console.ReadLine();

            // Stop the server.
            Console.WriteLine("The server is stopping...");
            server.Stop();

            Console.WriteLine("The server is stopped.");
        }
    }
}
' This example shows how to create data variables nested in folders or other data variables.
' You can use any OPC UA client, including our Connectivity Explorer and OpcCmd utility, to connect to the server. 
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET .
' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
' a commercial license in order to use Online Forums, and we reply to every post.

Imports System
Imports OpcLabs.EasyOpc.UA
Imports OpcLabs.EasyOpc.UA.NodeSpace

Namespace _UADataVariable
    Partial Friend Class _Building
        Shared Sub Nested()
            ' Instantiate the server object.
            ' By default, the server will run on endpoint URL "opc.tcp://localhost:48040/".
            Dim server = New EasyUAServer()

            ' Create a data variable, and another data variable nested inside it.
            server.Add(New UADataVariable("Constant") From
                {
                    New UADataVariable("NestedConstant").ConstantValue("abc")
                }.ConstantValue(42))

            ' Create a folder, and a data variable nested inside it.
            server.Add(New UAFolder("Folder") From
                {
                    New UADataVariable("ReadWrite").ReadWriteValue(0) ' read - Write() register
                })

            ' Start the server.
            Console.WriteLine("The server is starting...")
            server.Start()

            Console.WriteLine("The server is started.")
            Console.WriteLine()

            ' Let the user decide when to stop.
            Console.WriteLine("Press Enter to stop the server...")
            Console.ReadLine()

            ' Stop the server.
            Console.WriteLine("The server is stopping...")
            server.Stop()

            Console.WriteLine("The server is stopped.")
        End Sub
    End Class
End Namespace

Effective Node Ids and Browse Paths

In OPC UA, the primary means of identifying a node in the address space is the Node Id (see OPC UA Node IDs). The OPC Wizard takes care of creating the node IDs for the nodes you define. It places all nodes under a common namespace, controlled by the ObjectsNamespaceUriString Property of the EasyUAServer object. OPC Wizard uses string identifiers for the node Ids, and constructs the string by concatenating the node names (starting from the first level under the Objects folder), and separating them with a dot ('.').

If you need to know the actual (effective) node Id of any node that you have defined and placed in the address space of the server, retrieve its EffectiveNodeDescriptor Property. The effective node descriptor contains the effective node Id, and also the browse path for the node, starting at the Objects folder.

The following example illustrates how the effective node descriptors can be obtained.

.NET

// This example shows how to obtain the effective node descriptors of server nodes (i.e. their node IDs and browse paths).
// You can use any OPC UA client, including our Connectivity Explorer and OpcCmd utility, to connect to the server. 
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client, server and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-OPCStudio-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.NodeSpace;

namespace UAServerDocExamples._UAServerNode
{
    class EffectiveNodeDescriptor
    {
        public static void Main1()
        {
            // Instantiate the server object.
            // By default, the server will run on endpoint URL "opc.tcp://localhost:48040/".
            var server = new EasyUAServer();

            // Define some nodes in the server.
            var dataVariable1 = UADataVariable.CreateIn(server.Objects, "DataVariable1");
            var folder1 = UAFolder.CreateIn(server.Objects, "Folder1");
            var dataVariable2 = UADataVariable.CreateIn(folder1, "DataVariable2");

            // Display the node Ids (including the namespace URI).
            Console.WriteLine();
            Console.WriteLine(server.Objects.EffectiveNodeDescriptor.NodeId);
            Console.WriteLine(dataVariable1.EffectiveNodeDescriptor.NodeId);
            Console.WriteLine(folder1.EffectiveNodeDescriptor.NodeId);
            Console.WriteLine(dataVariable2.EffectiveNodeDescriptor.NodeId);

            // Display the browse paths.
            Console.WriteLine();
            Console.WriteLine(server.Objects.EffectiveNodeDescriptor.BrowsePath);
            Console.WriteLine(dataVariable1.EffectiveNodeDescriptor.BrowsePath);
            Console.WriteLine(folder1.EffectiveNodeDescriptor.BrowsePath);
            Console.WriteLine(dataVariable2.EffectiveNodeDescriptor.BrowsePath);
        }
    }
}
' This example shows how to obtain the effective node descriptors of server nodes (i.e. their node IDs and browse paths).
' You can use any OPC UA client, including our Connectivity Explorer and OpcCmd utility, to connect to the server. 
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET .
' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
' a commercial license in order to use Online Forums, and we reply to every post.

Imports System
Imports OpcLabs.EasyOpc.UA
Imports OpcLabs.EasyOpc.UA.NodeSpace

Namespace _UAServerNode
    Partial Friend Class EffectiveNodeDescriptor
        Shared Sub Main1()
            ' Instantiate the server object.
            ' By default, the server will run on endpoint URL "opc.tcp://localhost:48040/".
            Dim server = New EasyUAServer()

            ' Define some nodes in the server.
            Dim dataVariable1 = UADataVariable.CreateIn(server.Objects, "DataVariable1")
            Dim folder1 = UAFolder.CreateIn(server.Objects, "Folder1")
            Dim dataVariable2 = UADataVariable.CreateIn(folder1, "DataVariable2")

            ' Display the node Ids (including the namespace URI).
            Console.WriteLine()
            Console.WriteLine(server.Objects.EffectiveNodeDescriptor.NodeId)
            Console.WriteLine(dataVariable1.EffectiveNodeDescriptor.NodeId)
            Console.WriteLine(folder1.EffectiveNodeDescriptor.NodeId)
            Console.WriteLine(dataVariable2.EffectiveNodeDescriptor.NodeId)

            ' Display the browse paths.
            Console.WriteLine()
            Console.WriteLine(server.Objects.EffectiveNodeDescriptor.BrowsePath)
            Console.WriteLine(dataVariable1.EffectiveNodeDescriptor.BrowsePath)
            Console.WriteLine(folder1.EffectiveNodeDescriptor.BrowsePath)
            Console.WriteLine(dataVariable2.EffectiveNodeDescriptor.BrowsePath)
        End Sub
    End Class
End Namespace

Searching and Navigating in the Node Space

Sometimes there is a need to find certain node in the node space, or traverse through the nodes in a specific way. Since you are writing the code that constructs the nodes and relates them together, you can always store references to the nodes you have created - as you are creating them - into any kind of data structure that suits the lookup or navigation needs, and use this data structure when needed. That is actually the preferred approach, because you can implement it in a way that is both convenient and efficient in your application.

In absence of your own lookup or traversal structures, you can use the built-in features in the OPC Wizard to search and navigate through the nodes. Following are the main means of doing so:

.NET

// This example shows how sub-nodes of server nodes can be accessed by their node name using an indexer.
// You can use any OPC UA client, including our Connectivity Explorer and OpcCmd utility, to connect to the server. 
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client, server and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-OPCStudio-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.NodeSpace;

namespace UAServerDocExamples._UAServerNode
{
    class Indexer
    {
        public static void Main1()
        {
            // Instantiate the server object.
            // By default, the server will run on endpoint URL "opc.tcp://localhost:48040/".
            var server = new EasyUAServer();

            // Define some nodes in the server.
            UADataVariable constantDataVariable = UADataVariable.CreateIn(server.Objects, "Constant").ConstantValue("abc");
            UADataVariable nestedConstantDataVariable = UADataVariable.CreateIn(constantDataVariable, "NestedConstant").ConstantValue(42);
            
            // Get the nested constant data variable.
            UAServerNode serverNode1 = server.Objects["Constant"]["NestedConstant"];
            Console.WriteLine(serverNode1);
        }
    }
}
' This example shows how sub-nodes of server nodes can be accessed by their node name using an indexer.
' You can use any OPC UA client, including our Connectivity Explorer and OpcCmd utility, to connect to the server. 
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET .
' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
' a commercial license in order to use Online Forums, and we reply to every post.

Imports System
Imports OpcLabs.EasyOpc.UA
Imports OpcLabs.EasyOpc.UA.NodeSpace

Namespace _UAServerNode
    Partial Friend Class Indexer
        Shared Sub Main1()
            ' Instantiate the server object.
            ' By default, the server will run on endpoint URL "opc.tcp://localhost:48040/".
            Dim server = New EasyUAServer()

            ' Define some nodes in the server.
            Dim constantDataVariable As UADataVariable = UADataVariable.CreateIn(server.Objects, "Constant").ConstantValue("abc")
            Dim nestedConstantDataVariable As UADataVariable = UADataVariable.CreateIn(constantDataVariable, "NestedConstant").ConstantValue(42)

            ' Get the nested constant data variable.
            Dim serverNode1 As UAServerNode = server.Objects("Constant")("NestedConstant")
            Console.WriteLine(serverNode1)
        End Sub
    End Class
End Namespace

 

See Also

Examples - Server OPC Unified Architecture

Reference

Concepts

External